package com.bw.a525zy

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import com.blankj.utilcode.util.ToastUtils
import com.bw.a525zy.New.NewApter
import com.bw.a525zy.New.NewViewModel
import com.bw.a525zy.New1.NeApter1
import com.bw.a525zy.New1.NewViewModel1
import com.bw.a525zy.databinding.ActivityMainBinding
import com.bw.base.mvvm.BaseActivity
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch

@AndroidEntryPoint
class MainActivity : BaseActivity<ActivityMainBinding,NewViewModel1>(){
   lateinit var newApter1: NeApter1

    override fun initView() {
//        binding.rv.apply {
//            adapter=newApter
//        }
//        lifecycleScope.launch {
//            vm.NewResUlt().collect{
//                newApter.submitData(it)
//            }
//        }
        newApter1=NeApter1()
      binding.rv.adapter=newApter1
        vm.getNew()

    }

    override fun intiData() {
        vm.NewSuccess.observe(this){
           newApter1.data.clear()
            newApter1.data.addAll(it)
                newApter1.notifyDataSetChanged()
        }
    }
}